<?php
function is_com_role($r)
{
	return $r==$_SESSION[C('USER_ROLE_ID')];
}
function m5($ps)
{
	$ts=md5($ps);
	return substr($ts,4,8).substr($ts,20,8);
}
function sr()
{
	return intval($_SESSION[C('USER_ROLE_ID')]);
}
function my_filter($in)
{
	return str_replace("'","''",$in);
}
function SendMsg($phone,$fromName,$subject,$message)
{

vendor('PHPMailer/class#phpmailer');

$mail = new PHPMailer(); //建立邮件发送类
$address = "$phone@139.com";
$mail->IsSMTP(); // 使用SMTP方式发送
$mail->Host = "smtp.126.com"; // 您的企业邮局域名
$mail->SMTPAuth = true; // 启用SMTP验证功能
$mail->Username = "supermails@126.com"; // 邮局用户名(请填写完整的email地址)
$mail->Password = "597641"; // 邮局密码
$mail->CharSet="utf-8";

$mail->Encoding="base64";
$mail->From = "supermails@126.com"; //邮件发送者email地址
$mail->FromName = $fromName;
$mail->AddAddress($address, "收件人");//收件人地址，可以替
$mail->Subject = $subject; //邮件标题
$mail->Body =$message;
//$mail->IsHTML(true);
$ds='';

$r=$mail->Send();

	if($r)
		return '{"summary":"success","desc":"'.$ds.'"}';
	else
		return '{"summary":"'.$mail->ErrorInfo.'"}';
}
?>